class Solution
{
public:
    vector<string> sortPeople(vector<string> &names, vector<int> &heights)
    {
        int n = names.size();
        vector<int> indexMap(n);
        iota(indexMap.begin(), indexMap.end(), 0);
        sort(indexMap.begin(), indexMap.end(), [&](int i1, int i2)
             { return heights[i1] > heights[i2]; });
        vector<string> result;
        for (int i = 0; i < n; ++i)
        {
            result.push_back(names[indexMap[i]]);
        }
        return result;
    }
};